#include "LuaLink_Widget_Delegate.h"

LuaLink_Widget_Delegate::LuaLink_Widget_Delegate(luabind::object function)
{
	this->luaFunction = function;
}

LuaLink_Widget_Delegate::~LuaLink_Widget_Delegate(void)
{
}

void LuaLink_Widget_Delegate::executeEvent(MyGUI::WidgetPtr _widget) {
	if (luaFunction) {
		try {
			call_function<void>(luaFunction);
		} catch (luabind::error& error) {
			LuaLink_Trace::trace("LUA ERROR ON eventDelegate:");
			LuaLink_Trace::trace(error.what());
		}
	}
}

void LuaLink_Widget_Delegate::executeEventWidget(MyGUI::WidgetPtr _widget) {
	if (luaFunction) {
		try {
			call_function<void>(luaFunction);
		} catch (luabind::error& error) {
			LuaLink_Trace::trace("LUA ERROR ON eventDelegate:");
			LuaLink_Trace::trace(error.what());
		}
	}
}
